﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FCTC_Web.Models;
using DAL;

namespace FCTC_Web.Controllers.Business.BusinessModel
{
    public class Banners
    {
        public static Banners _ins = new Banners();
        public static Banners Ins
        {
            get { return _ins; }
        }

        public List<Vehicle> RecommandedVehicles
        {
            get
            {
                return CH.GetAllData<Vehicle>().OrderByDescending(i=>i.Sequense).ToList();
            }
        }



        public List<Estimator> RecommandedEstimators
        {
            get
            {
                return CH.GetAllData<Estimator>().OrderByDescending(i => i.Sequense).ToList(); ;
            }
        }
        public List<Shop> RecommandedShops
        {
            get
            {
                return CH.GetAllData<Shop>().OrderByDescending(i => i.Sequense).ToList(); ;
            }
        }

        public List<Shop> Recommanded4S
        {
            get
            {
                return CH.GetAllData<Shop>().FindAll(i => i.ShopType == "4S车店").OrderByDescending(i => i.Sequense).ToList();
            }
        }

        public List<Shop> RecommandedSecondHandVehicleShop
        {
            get
            {
                return CH.GetAllData<Shop>().FindAll(i => i.ShopType == "二手车店").OrderByDescending(i=>i.Sequense).ToList();
            }
        }
    }

    public class BusinessBase
    {
        public Banners Banners
        {
            get { return Banners.Ins; }
        }
    }

    public class DefaultModel : BusinessBase
    {
        public DefaultModel()
        {
            Articles =  CH.GetAllData<Article>().OrderBy(i=>i.Sequense).ToList();
            OnsaleVehicles = CH.GetAllData<Vehicle>(i => i.VehicleStatus == "热卖").OrderBy(i=>i.Sequense).ToList();
            Estimators = CH.GetAllData<Estimator>().OrderBy(i => i.Sequense).ToList();
        }
        public static DefaultModel _ins = new DefaultModel();
        public static DefaultModel Default
        {
            get 
            { 
                return _ins; 
            }
        }


        public List<Article> Articles { get; set; }
        public List<Estimator> Estimators { get; set; }
        public List<Vehicle> OnsaleVehicles { get; set; }

        #region Vehicles
        public List<Vehicle> LatestVehicles
        {
            get { return OnsaleVehicles.OrderBy(i => i.EnrollmentDate).ToList(); }
        }
        public List<Vehicle> SpecialOffers
        {
            get { return OnsaleVehicles.FindAll(i => i.SpecialOffer).OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Vehicle> Cars
        {
            get { return OnsaleVehicles.FindAll(i => i.Category == "轿车").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Vehicle> BusinessVehicle
        {
            get { return OnsaleVehicles.FindAll(i => i.Category == "商务车").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Vehicle> Transportion
        {
            get { return OnsaleVehicles.FindAll(i => i.Category == "客车").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Vehicle> SUV
        {
            get { return OnsaleVehicles.FindAll(i => i.Category == "越野车").OrderByDescending(i => i.Sequense).ToList(); }
        }
        #endregion

        #region banners

        #endregion
        #region Estimators
     

        #endregion


        #region articles
        public List<Article> MarketNews
        {
            get { return Articles.FindAll(i => i.ArticleType == "市场").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> QA
        {
            get { return Articles.FindAll(i => i.ArticleType == "问答").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Auctions
        {
            get { return Articles.FindAll(i => i.ArticleType == "拍卖").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Knowledge
        {
            get { return Articles.FindAll(i => i.ArticleType == "知识").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> VehicleShows
        {
            get { return Articles.FindAll(i => i.ArticleType == "车展").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> Activities
        {
            get { return Articles.FindAll(i => i.ArticleType == "活动").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> NewVechiles
        {
            get { return Articles.FindAll(i => i.ArticleType == "新车").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Policies
        {
            get { return Articles.FindAll(i => i.ArticleType == "政策").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Discount4S
        {
            get { return Articles.FindAll(i => i.ArticleType == "促销").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> Brands
        {
            get { return Articles.FindAll(i => i.ArticleType == "品牌").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> Documents
        {
            get { return Articles.FindAll(i => i.ArticleType == "文档").OrderByDescending(i => i.Sequense).ToList(); }
        }
        #endregion

   
    }
}